using System;
using System.Linq;
using System.Reflection;

namespace HQLAddin.ConfigurationInspector
{
	public class NhTypes
	{
		private static Assembly CurrentAssembly()
		{
			return AppDomain.CurrentDomain.GetAssemblies().ToArray()
				.Last(asse => !string.IsNullOrEmpty(asse.FullName) 
				              && asse.FullName.StartsWith("NHibernate, "));
		}

		public static Type Configuration
		{
			get { return CurrentAssembly().GetType("NHibernate.Cfg.Configuration"); }
		}

		public static Type Component
		{
			get { return CurrentAssembly().GetType("NHibernate.Mapping.Component"); }
		}

		public static Type Collection
		{
			get { return CurrentAssembly().GetType("NHibernate.Mapping.Collection"); }
		}

		public static Type ToOne
		{
			get { return CurrentAssembly().GetType("NHibernate.Mapping.ToOne"); }
		}

		public static Type OneToMany
		{
			get { return CurrentAssembly().GetType("NHibernate.Mapping.OneToMany"); }
		}
	}
}